<?php

namespace App\Api\Controllers;


use App\Models\Feedback;
use Dingo\Api\Http\Request;
use Dingo\Api\Routing\Helpers;
use Illuminate\Routing\Controller;

class FeedbackController extends Controller
{
    use Helpers;

    public function store(Request $request)
    {
       $user=$this->auth->user();
       if(!$request->feedContent){
           return $this->response->array([
               'status_code'=>201,
               'message'=>'内容不能为空',
           ]);
       }
       $feedbackData=Feedback::create([
           'user_id'=>$user->id,
           'content'=>$request->feedContent,
           'readed'=>0,
           'from'=>0
       ]);
       if($feedbackData){
           return $this->response->array([
               'status_code'=>200,
               'message'=>'感谢您为我们提出宝贵意见',
           ]);
       }else{
           return $this->response->array([
               'status_code'=>201,
               'message'=>'服务器开了个小差',
           ]);
       }
    }
}
